﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;

using Matchingo.Common.Types.Interfaces;

namespace Matchingo.Modules.AboutScreenModule.Views
{
    public partial class AboutScreenView : UserControl, IAboutScreenView
    {
        #region ========== Local Members ===========

        // Constants
        private const string STORYBOARD_SLIDEIN = "SlideInDownStoryboard";
        private const string STORYBOARD_SLIDEOUT = "SlideOutDownStoryboard";

        // Private Members
        private AboutScreenViewModel ViewModel { get; set; }

        #endregion

        public UIElement RootElement { get { return this.LayoutRoot; } }

        public AboutScreenView()
        {
            InitializeComponent();
        }

        #region ========== Public Methods ==========

        public void Initialize(AboutScreenViewModel model)
        {
            ViewModel = model;
            DataContext = ViewModel;
        }

        public void ShowScreen(bool skipAnimation)
        {
            PlayStoryboard(STORYBOARD_SLIDEIN, skipAnimation);
        }

        public void HideScreen(bool skipAnimation)
        {
            PlayStoryboard(STORYBOARD_SLIDEOUT, skipAnimation);
        }

        #endregion

        #region ========== Private Methods ==========

        private void PlayStoryboard(string storyBoardName, bool skipAnimation)
        {
            Application.Current.RootVisual.Dispatcher.BeginInvoke(() =>
            {
                Storyboard sb = (Storyboard)Resources[storyBoardName];
                sb.Begin();
                if (skipAnimation)
                {
                    sb.SkipToFill();
                }
            });
        }

        #endregion

        #region ========== Event Handlers ==========

        private void TwitterButton_Clicked(object sender, RoutedEventArgs e)
        {
            ViewModel.VisitTwitterWebsite();
        }

        private void AuthorWebsiteButton_Clicked(object sender, RoutedEventArgs e)
        {
            ViewModel.VisitAuthorWebsite();
        }

		private void MichaelUrvanWebsiteButton_Clicked(object sender, RoutedEventArgs e)
		{
			ViewModel.VisitMichaelUrvanWebsite();
		}
		
		private void GameWebsiteButton_Clicked(object sender, RoutedEventArgs e)
        {
            ViewModel.VisitGameWebsite();
        }

        private void CrystalIconsProjectButton_Clicked(object sender, RoutedEventArgs e)
        {
            ViewModel.VisitCrystalProjectWebsite();
        }

        private void CodePlexLink_Clicked(object sender, MouseButtonEventArgs e)
        {
            ViewModel.VisitCodePlexWebsite();
        }

        private void SilverlightLink_Clicked(object sender, MouseButtonEventArgs e)
        {
            ViewModel.VisitSilverlightWebsite();
        }

        private void CreativeCommonsLink_Clicked(object sender, MouseButtonEventArgs e)
        {
            ViewModel.VisitCreativeCommonsWebsite();
        }

        #endregion
    }
}
